/*
 * Copyright 2014 OGIS-RI All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jp.co.ogis_ri.optaplanner.vehiclerouting.domain;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import jp.co.ogis_ri.optaplanner.vehiclerouting.domain.core.AbstractPersistable;
import jp.co.ogis_ri.optaplanner.vehiclerouting.domain.core.ChainedTimeWindowedStep;

import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;
import org.optaplanner.core.api.domain.solution.PlanningSolution;
import org.optaplanner.core.api.domain.solution.Solution;
import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
import org.optaplanner.core.api.score.buildin.hardsoftbigdecimal.HardSoftBigDecimalScore;

@PlanningSolution
public class VehicleRoutingSolution extends AbstractPersistable implements
		Solution<HardSoftBigDecimalScore> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */
	protected String name;

	/**
	 * 
	 */
	protected List<Location> locationList;

	/**
	 * 
	 */
	protected List<Depot> depotList;

	/**
	 * 
	 */
	protected List<Vehicle> vehicleList;

	/**
	 * 
	 */
	protected SolutionParameter solutionParameter;

	/**
	 * 
	 */
	protected List<ChainedTimeWindowedStep> cargoList;

	/**
	 * 
	 */
	protected HardSoftBigDecimalScore score;

	/**
	 * 
	 * @return
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * 
	 * @param name
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * 
	 * @return
	 */
	public List<Location> getLocationList() {
		return this.locationList;
	}

	/**
	 * 
	 * @param locationList
	 */
	public void setLocationList(final List<Location> locationList) {
		this.locationList = locationList;
	}

	/**
	 * 
	 * @return
	 */
	public List<Depot> getDepotList() {
		return this.depotList;
	}

	/**
	 * 
	 * @param depotList
	 */
	public void setDepotList(final List<Depot> depotList) {
		this.depotList = depotList;
	}

	/**
	 * 
	 * @return
	 */
	@PlanningEntityCollectionProperty
	@ValueRangeProvider(id = "vehicleRange")
	public List<Vehicle> getVehicleList() {
		return this.vehicleList;
	}

	/**
	 * 
	 * @param vehicleList
	 */
	public void setVehicleList(final List<Vehicle> vehicleList) {
		this.vehicleList = vehicleList;
	}

	/**
	 * 
	 * @return
	 */
	@PlanningEntityCollectionProperty
	@ValueRangeProvider(id = "cargoRange")
	public List<ChainedTimeWindowedStep> getCargoList() {
		return this.cargoList;
	}

	/**
	 * 
	 * @param cargoList
	 */
	public void setCargoList(final List<ChainedTimeWindowedStep> cargoList) {
		this.cargoList = cargoList;
	}

	/**
	 * 
	 */
	@Override
	public HardSoftBigDecimalScore getScore() {
		return this.score;
	}

	/**
	 * 
	 */
	@Override
	public void setScore(final HardSoftBigDecimalScore score) {
		this.score = score;
	}

	/**
	 * 
	 * @return
	 */
	public SolutionParameter getSolutionParameter() {
		return this.solutionParameter;
	}

	/**
	 * 
	 * @param solutionParameter
	 */
	public void setSolutionParameter(final SolutionParameter solutionParameter) {
		this.solutionParameter = solutionParameter;
	}

	// ************************************************************************
	// Complex methods
	// ************************************************************************

	/**
	 * 
	 */
	@Override
	public Collection<? extends Object> getProblemFacts() {
		List<Object> facts = new ArrayList<Object>();
		facts.addAll(this.locationList);
		facts.addAll(this.depotList);
		facts.add(this.solutionParameter);
		// Do not add the planning entity's (cargoList) because that will be
		// done automatically
		return facts;
	}

}
